from api.ihrmLogin import IhrmloginApi
#参数化
import pytest   #导包 @pytest.mark.parametrize用
from api.ihrmLogin import IhrmloginApi  # 导包接口 res = self.ihrm_login.login(req_body)req_body:数据
from common.assertTools import common_assret  # 导包断言 common_assret(res, status_code, success, code, message)
from common.readJsonTools import read_json_filr #导包读文件成[(),()]
from config import project_path #导包路径    filename = project_path + "/data/loginData.json" 读文件的参数



class TestIhrmLoginApi(object): #定义测试类

    def setup_class(self):#优化
        self.ihrm_login = IhrmloginApi()

    filename = project_path + "/data/loginData.json" #路径
    data = read_json_filr(filename) #读文件

    @pytest.mark.parametrize("desc,req_body,status_code,success,code,message", data) #参数化装饰器 二个参数
    def test_login(self, desc, req_body, status_code, success, code, message): #加形参
        res = self.ihrm_login.login(req_body) #导入接口创建实例
        print(desc,":", res.json()) #打印结果
        # 断言
        common_assret(res, status_code, success, code, message)

